treeview: Clip to bin window size when drawing bin window
authorBenjamin Otte <otte@redhat.com>
Mon, 31 Oct 2016 23:03:03 +0000 (00:03 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 1 Nov 2016 02:51:48 +0000 (03:51 +0100)
This ensures that the drawing does not extend the actually drawn area.

It also ensures that our math is sane, because the math assumes the clip
area cannot extend the window. After all, before GTK4 it always was like
that.

Fixes a bunch of drawing bugs when the clip area does indeed extend too
far.

gtk/gtktreeview.c

index 010d09476b1261dbc59904fa92b071b809f9513e..bc6aa74fa532cef324c11dc80ddef43006355f56 100644 (file)
@@ -4944,13 +4944,13 @@ gtk_tree_view_bin_draw (GtkWidget      *widget,
 
   bin_window_width = gdk_window_get_width (tree_view->priv->bin_window);
   bin_window_height = gdk_window_get_height (tree_view->priv->bin_window);
+  cairo_rectangle (cr, 0, 0, bin_window_width, bin_window_height);
+  cairo_clip (cr);
+
   if (!gdk_cairo_get_clip_rectangle (cr, &clip))
     return TRUE;
 
   new_y = TREE_WINDOW_Y_TO_RBTREE_Y (tree_view, clip.y);
-
-  if (new_y < 0)
-    new_y = 0;
   y_offset = -_gtk_rbtree_find_offset (tree_view->priv->tree, new_y, &tree, &node);
 
   if (gtk_tree_view_get_height (tree_view) < bin_window_height)